// 指定图表的配置项和数据

var myCharts = {
    // 柱状图
    charts_bar: function (bar_title, legend_data, data) {
        return {
            title: {
                text: bar_title
            },
            tooltip: {},
            legend: {
                data: [legend_data]
            },
            xAxis: {
                data: data['name']
            },
            yAxis: {},
            series: [{
                name: legend_data,
                type: 'bar',
                data: data['count']
            }]
        };
    },

    // 饼状图
    charts_pie: function (pie_title, legend_data, data) {

        var name_length = data['name'].length;

        var datas = [];
        for (var index = 0; index < name_length; index++) {
            name = data['name'][index]
            count = data['count'][index]

            datas.push({
                'value': count, 'name': name
            });
        }

        return {
            title: {
                text: pie_title,
                subtext: '',
                left: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{a} <br/>{b} : {c} ({d}%)'
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: data['name']
            },
            series: [
                {
                    name: legend_data,
                    type: 'pie',
                    radius: '55%',
                    center: ['50%', '60%'],
                    data: datas,
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };

    },

    // 条形图
    negative: function (data2) {
        return {
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: ['总量', '已通过','审核中']
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'value'
                }
            ],
            yAxis: [
                {
                    type: 'category',
                    axisTick: {
                        show: false
                    },
                    data: data2['name']
                }
            ],
            series: [
                {
                    name: '已通过',
                    type: 'bar',
                    label: {
                        show: true
                    },
                    data: data2['through_count']
                },
                {
                    name: '审核中',
                    type: 'bar',
                    label: {
                        show: true
                    },
                    data: data2['auditing_count']
                },
                {
                    name: '总量',
                    type: 'bar',
                    label: {
                        show: true,
                        position: 'inside'
                    },
                    data: data2['count']

                }
            ]
        };

    }




}